<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
   class Login extends Admin_Controller
   {
      function __construct()
      {
         parent::__construct();
      }
      function index()
      {
      	 $user=$this->session->userdata('user');
      	 $pwd =$this->session->userdata('password');
      	 if($user && $pwd)
      	 {
      	 	$time=time();
      		$this->load->model('User_model');
      		$res=$this->User_model->login($user,$pwd);
      	    if($res)
      	    {
      	    	$login_update = array(
      	    	      'lastloginip'=>$this->input->ip_address(),
      	    	      'lastlogintime'=>time(),
      	    	);
                $this->User_model->update($res['adminid'],$login_update);
      	  	    $data['sys_info']=get_sysinfo();
      	  	    $data['adminname']=$user;
		        $this->load->view('admin/main',$data);
      	     }
         }else
         {
         	 $this->load->view('admin/admin_login');
         }
      }
      function code_img()
      {
      	$this->load->library('checkcode');
		$this->checkcode->doimage();
		$sess_code = $this->checkcode->get_code();
		$this->session->set_userdata('sess_code',$sess_code);
      }
   }
?>   